﻿<!--#include file="const.asp"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>


<%
if sid="Null" then
	Response.Redirect "login.asp"
	Response.end
end if
%>
	<card title="友链列表管理"><p align="left">
<%
	dim rs,sql,page,i,classid
    		classid = Request("classid")
    		If classid = "" Then classid = 0
   		If Not IsNumeric(classid) Then classid = 0
    		classid = CLng(classid)
    		If classid < 0 Then classid = 0

    		Page = Request("page")      '当前页数
    		If Page = "" Then Page = 1
   		If Not IsNumeric(Page) Then Page = 1
    		Page = CLng(Page)
    		If Page < 1 Then Page = 1
%>
	[<a href="/link/add.asp">添加新友链</a>]<br/>
<%
	if Request("show")="true" and  Request("id")<>"" then
			conn.execute("update [qingtian_link_list] set [show]=1  where  id="&Request("id")&"")
	elseif Request("show")="false" and  Request("id")<>""  then
			conn.execute("update [qingtian_link_list] set [show]=0  where  id="&Request("id")&"")
	end if


	Set Rs = Server.CreateObject("Adodb.Recordset")
	if classid>0 then
	Sql = "SELECT a.id,a.name,a.show,a.classid,b.name from qingtian_link_list a,qingtian_link_class b where a.classid=b.id and a.classid="&classid&" order by a.id desc"
	else
	Sql = "SELECT a.id,a.name,a.show,a.classid,b.name from qingtian_link_list a,qingtian_link_class b where a.classid=b.id  order by a.id desc"
	end if
		Rs.Open Sql,conn,1,1
		if not (rs.bof and rs.eof)  then
				Rs.PageSize = 10	'一页N条记录
				IF Not IsEmpty(Page) Then
					IF Not IsNumeric(Page) Then		'判断Page是否为数字
						Page=1
					Else
						Page=Cint(Page)		'转换成短整形Integer
					End IF
					IF Page > Rs.PageCount Then
						Rs.AbsolutePage = Rs.PageCount	'设置当前显示页等于最后一页
					ElseIF Page <= 0 Then
						Rs.AbsolutePage = 1		'设置当前页等于第一页
					Else
						Rs.AbsolutePage = Page	'如果大于零,显示当前页等于接收的页数
					End IF
				Else
					Rs.AbsolutePage = 1
				End IF
				Page = Rs.AbsolutePage


		For i=1 to  Rs.PageSize
		If Rs.Eof Then
			exit For
		End If
			%><%=i+(page-1)*Rs.PageSize%>:友链分类:<a href="linklist.asp?classid=<%=rs("classid")%>&amp;sid=<%=sid%>"><%=qingtian.utf8(rs("b.name"))%></a><br/>
			名称:<%=qingtian.utf8(rs("a.name"))%><%if rs("show")=0 then%><b>[未审核]</b><%end if%><br/>
			[<%if rs("show")=0 then%><a href="linklist.asp?show=true&amp;id=<%=rs("id")%>&amp;classid=<%=classid%>&amp;page=<%=page%>&amp;sid=<%=sid%>">审核</a><%else%><a href="linklist.asp?show=false&amp;id=<%=rs("id")%>&amp;classid=<%=classid%>&amp;page=<%=page%>&amp;sid=<%=sid%>">反审核</a><%end if%>|<a href="editlinklist.asp?classid=<%=classid%>&amp;page=<%=page%>&amp;id=<%=rs("id")%>&amp;sid=<%=sid%>">修改</a>|<a href="dellinklist.asp?classid=<%=classid%>&amp;page=<%=page%>&amp;id=<%=rs("id")%>&amp;sid=<%=sid%>">删除</a>]<br/><%
	 	Rs.MoveNext
	  	Next

       
    		'分页
    		If Page < rs.PageCount Then
    		    Response.Write("<a href='linklist.asp?classid=" & classid & "&amp;page=" & Page + 1 & "&amp;sid=" & sid & "'>下一页</a>")
    		End If
       
    		If Page > 1 And Page < rs.PageCount Then
    		    Response.Write("|")
    		End If
        
    		If Page > 1 Then
    		    Response.Write("<a href='linklist.asp?classid=" & classid & "&amp;page=" & Page - 1 & "&amp;sid=" & sid & "'>上一页</a><br/>")
    		Elseif rs.PageCount >1 then
    		    Response.Write("<br/>")
    		End If
            
    		Randomize()
    
    		If rs.PageCount > 2 Then
    		    Response.Write("<input name='Page' format='*N' size='5' maxlength='5'/>")
    		    Response.Write("<anchor>跳页")
    		    Response.Write("<go href='linklist.asp?classid=" & classid & "&amp;run=" & Int((9999) * Rnd() + 1) & "&amp;sid=" & sid & "' method='post'>")
    		    Response.Write("<postfield name='Page' value='$(Page:n)' />")
    		    Response.Write("</go></anchor><br/>")
    		End If
     		    Response.Write("[第"&Page&"/总"&rs.PageCount&"页/"&rs.RecordCount&"条]<br/>")

		end if
		Rs.close

			
	set rs=nothing
		if classid>0 then Response.Write("<a href='linklist.asp?sid=" & sid & "'>查看全部友链</a><br/>")
   		Response.Write("<a href='linkv.asp?sid=" & sid & "'>返回友链管理</a><br/><a href='index.asp?sid=" & sid & "'>后台管理首页</a><br/>")
end Function
%>
